package com.shop.cereshop.business.param.business;

import com.shop.cereshop.commons.config.RsaProperties;
import com.shop.cereshop.commons.utils.RsaUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;

@Data
@ApiModel(value = "BussinessRegisterParam", description = "商家注册请求")
@Accessors(chain = true)
public class BussinessRegisterParam {

    @ApiModelProperty(value = "手机号", required = true)
    @NotBlank(message = "手机号不能为空")
    private String account;

    @ApiModelProperty(value = "验证码", required = true)
    @NotBlank(message = "验证码不能为空")
    private String verifyCode;

    @ApiModelProperty(value = "密码", required = true)
    @NotBlank(message = "密码不能为空")
    private String password;

    @ApiModelProperty(value = "邀请码")
    private String inviteCode;
    @ApiModelProperty(value = "商家类型  1线上商城  2同城入驻")
    private String  merchantType;

    @ApiModelProperty(value = "极光推送用户唯一标识")
    private String registerId;
    public BussinessRegisterParam decrypt() throws Exception{
        BussinessRegisterParam param = new BussinessRegisterParam();
        param.setAccount(RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,account));
        param.setPassword(RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,password));
        param.setVerifyCode(this.verifyCode);
        param.setInviteCode(this.inviteCode);
        param.setMerchantType(this.merchantType);
        return param;
    }
}
